GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

rename.js ➔ register_room_title_event   A
last analyzed

Complexity

Conditions 5

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 19
rs 9.3333
cc 5
1
// BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
2
//
3
// Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
4
//
5
// This program is free software; you can redistribute it and/or modify it under the
6
// terms of the GNU Lesser General Public License as published by the Free Software
7
// Foundation; either version 3.0 of the License, or (at your option) any later
8
// version.
9
//
10
// BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
11
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12
// PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
13
//
14
// You should have received a copy of the GNU Lesser General Public License along
15
// with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
16
17
$(document).on('turbolinks:load', function(){
18
  var controller = $("body").data('controller');
19
  var action = $("body").data('action');
20
21
  if(controller == "rooms" && action == "show" 
22
    || controller == "rooms" && action == "update" 
23
    || controller == "users" && action == "recordings" 
24
    || controller == "admins" && action == "server_recordings"){
25
26
    // Set a room header rename event
27
    var configure_room_header = function(room_title){
28
29
      function register_room_title_event(e){
30
        // Remove current window events
31
        $(window).off('mousedown keydown');
32
33
        if(e.type == 'focusout'){
34
          submit_rename_request(room_title);
35
          return;
36
        }
37
38
        room_title.addClass("dotted_underline");
39
        room_title.find('#user-text').fadeTo('medium', 0.7);
40
        room_title.find('#user-text').attr("contenteditable", true);
41
        room_title.find('#user-text').focus();
42
43
        // Stop automatic refresh
44
        e.preventDefault();
45
46
        register_window_event(room_title, 'user-text', '#edit-room', 'edit-room');
47
      }
48
49
      room_title.find('#user-text').on('dblclick focusout', function(e){
50
        if(room_title.find('#edit-room').length){
51
          register_room_title_event(e);
52
        }
53
      });
54
55
      room_title.find('.fa-edit').on('click', function(e){
56
        register_room_title_event(e);
57
      });
58
    }
59
60
    // Set a recording row rename event
61
    var configure_recording_row = function(recording_title){
62
63
      function register_recording_title_event(e){
64
        // Remove current window events
65
        $(window).off('mousedown keydown');
66
67
        if(e.type == 'focusout'){
68
          submit_rename_request(recording_title);
69
          return;
70
        }
71
72
        recording_title.addClass("dotted_underline");
73
        recording_title.fadeTo('medium', 0.7);
74
        recording_title.find('text').attr("contenteditable", true);
75
        recording_title.find('text').focus();
76
77
        // Stop automatic refresh
78
        e.preventDefault();
79
80
        register_window_event(recording_title, 'recording-text', '#edit-record', 'edit-recordid');
81
      }
82
83
      recording_title.find('a').on('click focusout', function(e){
84
        register_recording_title_event(e);
85
      });
86
87
      recording_title.find('#recording-text').on('dblclick focusout', function(e){
88
        register_recording_title_event(e);
89
      });
90
    }
91
92
    // Register window event to submit new name
93
    // upon click or upon pressing the enter key
94
    var register_window_event = function(element, textfield_id, edit_button_id, edit_button_data){
95
      $(window).on('mousedown keydown', function(clickEvent){
96
97
        // Return if the text is clicked
98
        if(clickEvent.type == "mousedown" && clickEvent.target.id == textfield_id){
99
          return;
100
        }
101
102
        // Return if the edit icon is clicked
103
        if(clickEvent.type == "mousedown" && $(clickEvent.target).is(edit_button_id) &&
104
          $(clickEvent.target).data(edit_button_data) === element.find(edit_button_id).data(edit_button_data)){
105
          return;
106
        }
107
108
        // Check if event is keydown and enter key is not pressed
109
        if(clickEvent.type == "keydown" && clickEvent.which !== 13){
110
          return;
111
        }
112
113
        clickEvent.preventDefault();
114
        submit_rename_request(element);
115
116
        // Remove window event when ajax call to update name is submitted
117
        $(window).off('mousedown keydown');
118
      });
119
    }
120
121
    // Apply ajax request depending on the element that triggered the event
122
    var submit_rename_request = function(element){
123
      if(element.is('#room-title')){
124
        submit_update_request({
125
          setting: "rename_header",
126
          name: element.find('#user-text').text(),
127
        }, element.data('path'), "POST");
128
      }
129
      else if(element.is('#recording-title')){
130
        submit_update_request({
131
          setting: "rename_recording",
132
          record_id: element.data('recordid'),
133
          record_name: element.find('text').text(),
134
          room_uid: element.data('room-uid'),
135
        }, element.data('path'), "PATCH");
136
      }
137
    }
138
139
    // Helper for submitting ajax requests
140
    var submit_update_request = function(data, path, action){
141
      // Send ajax request for update
142
      $.ajax({
143
        url: path,
144
        type: action,
145
        data: data,
146
      });
147
    }
148
149
    // Elements that can be renamed
150
    var room_title = $('#room-title');
151
    var recording_rows = $('#recording-table').find('tr');
152
153
    // Configure renaming for room header
154
    configure_room_header(room_title);
155
156
    // Configure renaming for recording rows
157
    recording_rows.each(function(){
158
      var recording_title = $(this).find('#recording-title');
159
      configure_recording_row(recording_title);
160
    });
161
  }
162
});
163